//
//  LGPatientBreatheReportCell.m
//  HeartDisease_YHJK
//
//  Created by 1234 on 2025/10/17.
//  市一 -- 慢阻肺、哮喘 -- 患者档案的Cell -- 检验、检查

#import "LGPatientBreatheReportCell.h"

@interface LGPatientBreatheReportCell()
/**   */
@property (nonatomic , strong)UILabel *titleLabel;
/**   */
@property (nonatomic , strong)UILabel *dateLabel;
/**   */
@property (nonatomic , strong)UIImageView *tipView;
/**   */
@property (nonatomic , strong)UILabel *contentLabel;

@end

@implementation LGPatientBreatheReportCell

-(instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier{
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if (self) {
        self.type = LGPositionTypeMiddle;
        [self createSubView];
    }
    return  self;
}

-(void)setDataDic:(NSDictionary *)dataDic{
    [super setDataDic:dataDic];
    self.titleLabel.text = LGNSString(dataDic[@"title"]);
    self.dateLabel.text = LGNSString(dataDic[@"date"]);
    self.dateLabel.hidden = [LGNSString(dataDic[@"date"]) isEmptyString]?YES:NO;
    self.contentLabel.text = LGNSString(dataDic[@"description"]);
    //1-检验 、 2-检查 、 3-量表 、 4-文本 、 5-聊下消息
    NSString *type = LGNSString(dataDic[@"item_type"]);
    NSString *contentColor = [type isEqualToString:@"1"]?@"#FF383C":@"#606266";
    self.contentLabel.textColor = [UIColor colorWithString:contentColor];
}


#pragma mark
#pragma mark ====> 创建控件
-(void)createSubView{
    [self.contentView addSubview:self.titleLabel];
    [self.contentView addSubview:self.dateLabel];
    [self.contentView addSubview:self.tipView];
    [self.contentView addSubview:self.contentLabel];
    [self.contentView addSubview:self.lineView];
    [self.titleLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(self.contentView).offset(viewPix(12));
        make.left.equalTo(self.contentView).offset(viewPix(12));
    }];
    [self.dateLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(self.titleLabel.mas_right).offset(viewPix(8));
        make.centerY.equalTo(self.titleLabel);
        make.width.equalTo(@(viewPix(86)));
        make.height.equalTo(@(viewPix(18)));
        make.right.lessThanOrEqualTo(self.contentView).offset(-viewPix(28));
    }];
    [self.tipView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.right.equalTo(self.contentView).offset(-viewPix(12));
        make.centerY.equalTo(self.titleLabel);
        make.width.height.equalTo(@(16));
    }];
    [self.contentLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(self.titleLabel.mas_bottom).offset(viewPix(10));
        make.left.equalTo(self.titleLabel);
        make.right.equalTo(self.contentView).offset(-viewPix(14));
        make.bottom.equalTo(self.contentView).offset(-viewPix(12));
    }];
    [self.lineView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(self.contentView).offset(viewPix(12));
        make.right.equalTo(self.contentView).offset(-viewPix(12));
        make.bottom.equalTo(self.contentView);
        make.height.equalTo(@(1));
    }];
}

-(UILabel *)titleLabel{
    if(!_titleLabel){
        _titleLabel = [UILabel lableWithText:@"" colorString:@"#282828" textFont:LGFont(16) textAlignment:NSTextAlignmentLeft lines:2];
        [_titleLabel setContentHuggingPriority:UILayoutPriorityRequired forAxis:UILayoutConstraintAxisHorizontal];
    }
    return _titleLabel;
}

-(UILabel *)dateLabel{
    if(!_dateLabel){
        _dateLabel = [UILabel lableWithText:@"" colorString:@"#5E8EF5" textFont:LGFont(14) textAlignment:NSTextAlignmentCenter lines:1];
        _dateLabel.backgroundColor = [UIColor colorWithString:@"#F0F3FD"];
        _dateLabel.hidden = YES;
    }
    return _dateLabel;
}

-(UILabel *)contentLabel{
    if(!_contentLabel){
        _contentLabel = [UILabel lableWithText:@"" colorString:@"#282828" textFont:LGFont(14) textAlignment:NSTextAlignmentLeft lines:0];
    }
    return _contentLabel;
}

-(UIImageView *)tipView{
    if(!_tipView){
        _tipView = [[UIImageView alloc]initWithImage:[UIImage imageNamed:@"grayTip16"]];
    }
    return _tipView;
}

-(UIView *)lineView{
    if(!_lineView){
        _lineView = [[UIView alloc]init];
        _lineView.backgroundColor = [UIColor colorWithString:@"#E0E0E0"];
    }
    return _lineView;
}

@end
